package org.stream;

import org.entity.Employee;
import org.junit.jupiter.api.Test;

/**
 * @Description
 * @Author wjj
 * @Date 2023/4/17 22:55
 */
public class Count {
    @Test
    public void countTest(){
        long count = Employee.persons().stream().count();
        System.out.println(count);
    }

    @Test
    public void countTest2(){
        long count = Employee.persons().stream()
                .mapToLong(p->1L)
                .sum();
        System.out.println(count);
    }

    @Test
    public void countTest3(){
        Long count = Employee.persons().stream()
                .map(p -> 1L)
                .reduce(0L, Long::sum);
        System.out.println(count);
    }

    @Test
    public void countTest4(){
        Long count = Employee.persons().stream()
                .reduce(0L, (partialCount,person)->partialCount+1L,Long::sum);
        System.out.println(count);
    }


}
